package com.basic.business.goodsLabel.controller;


import java.util.List;
import java.io.IOException;

import com.basic.business.goodsLabel.domain.TGoodsLabel;
import com.basic.business.goodsLabel.service.ITGoodsLabelService;
import org.springframework.security.access.prepost.PreAuthorize;
import javax.annotation.Resource;
import com.basic.common.annotation.FileExport;
import com.basic.common.utils.easyExcel.EasyExcelUtils;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.basic.common.annotation.Log;
import com.basic.common.core.controller.BaseController;
import com.basic.common.core.domain.AjaxResult;
import com.basic.common.enums.BusinessType;
import com.basic.common.core.page.TableDataInfo;
import org.springframework.web.multipart.MultipartFile;

/**
 * 商品标签管理Controller
 *
 * @author zhaoxy_jn@163.com
 */
@RestController
@RequestMapping("/business/goodsLabel")
public class TGoodsLabelController extends BaseController
{
    @Resource
    private ITGoodsLabelService tGoodsLabelService;

    /**
     * 查询商品标签管理列表
     */
    @PreAuthorize("@ss.hasPermi('business:goodsLabel:list')")
    @GetMapping("/list")
    public TableDataInfo list(TGoodsLabel tGoodsLabel)
    {
        startPage();
        List<TGoodsLabel> list = tGoodsLabelService.getList(tGoodsLabel);
        return getDataTable(list);
    }

    /**
     * 导出商品标签管理列表
     */
    @PreAuthorize("@ss.hasPermi('business:goodsLabel:export')")
    @Log(title = "商品标签管理", businessType = BusinessType.EXPORT)
    @FileExport(fileName = "商品标签管理.xlsx")
    @PostMapping("/export")
    public String export(TGoodsLabel tGoodsLabel) throws IOException
    {
        List<TGoodsLabel> list = tGoodsLabelService.getList(tGoodsLabel);
        return EasyExcelUtils.excelExport(TGoodsLabel.class,"商品标签管理数据", list);
    }

    /**
     * 获取商品标签管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('business:goodsLabel:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id)
    {
        return success(tGoodsLabelService.get(id));
    }

    /**
     * 新增商品标签管理
     */
    @PreAuthorize("@ss.hasPermi('business:goodsLabel:add')")
    @Log(title = "商品标签管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TGoodsLabel tGoodsLabel)
    {
        return toAjax(tGoodsLabelService.insert(tGoodsLabel));
    }

    /**
     * 修改商品标签管理
     */
    @PreAuthorize("@ss.hasPermi('business:goodsLabel:edit')")
    @Log(title = "商品标签管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TGoodsLabel tGoodsLabel)
    {
        return toAjax(tGoodsLabelService.update(tGoodsLabel));
    }

    /**
     * 删除商品标签管理
     */
    @PreAuthorize("@ss.hasPermi('business:goodsLabel:remove')")
    @Log(title = "商品标签管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable String[] ids)
    {
        return toAjax(tGoodsLabelService.deleteByIds(ids));
    }

    /**
     * 新增或修改商品标签管理
     */
    @PostMapping("/saveOrUpdate")
    public AjaxResult saveOrUpdate(@RequestBody TGoodsLabel tGoodsLabel)
    {
        return toAjax(tGoodsLabelService.saveOrUpdate(tGoodsLabel));
    }

    /**
     * 导入数据
     */
    @PostMapping("/importData")
    public AjaxResult importData(MultipartFile file)
    {
        tGoodsLabelService.importFileData(file);
        return success("文件数据导入成功");
    }
}
